<?php
namespace app\admin\controller;
use app\admin\controller\Auth;
use think\Db;
class Request extends Auth{
	public function requestList(){
		$list = Db::name('request')->where('is_del = 0')->paginate(20);
		$this->assign('list',$list);
		return $this->fetch();
	}
	// 处理需求
	public function readRequest(){
		$id = input('rid');
		if(empty($id)){
			$this->error('禁止非法操作');
			exit;
		}
		$where['id'] = array('EQ',$id);
		$data['is_read'] = 1;
		$result = Db::name('request')->where($where)->update($data);
		if($result){
			$this->redirect('/admin/request/requestList');
		}else{
			$this->error('修改失败');
		}
	}
	// 删除需求
	public function delRequest(){
		$id = input('rid');
		if(empty($id)){
			$this->error('禁止非法操作');
			exit;
		}
		$where['id'] = array('EQ',$id);
		$data['is_del'] = 1;
		$result = Db::name('request')->where($where)->update($data);
		if($result){
			$this->redirect('/admin/request/requestList');
		}else{
			$this->error('删除失败');
		}
	}
}